
<style>
.labels td {
	border-bottom: 2px #000000 solid;
	font-weight: bold;
	font-size: 90%;
}

.chart {
	background: #003300;
	color: #70E898;
	margin: auto;
	border: 1px #000000 solid;
	font-family: Verdana;
}
</style>

<script type="text/javascript">

function changeSelected(round)
{
	var url="<?php
echo $this->url(array('controller' => 'result'), 'default', true)?>"; 
		url+='?round='+round;

		    xmlHttpRequest = createXmlHttpRequest();       
		    xmlHttpRequest.onreadystatechange = Callback;       
		    xmlHttpRequest.open("post",url,true); 
		    xmlHttpRequest.send(null);   
	
	}

function getResult(delta){ 
//	 alert(delta);
	var round=document.getElementById("round");
	
    var index=round.selectedIndex;
	    
//	 alert("ok");
//  alert("index="+index);
    if((index>0&&delta<0)||(index!=round.options.length&&delta>0))
    {
	round.options[index+delta].selected =true;
	var url="<?php
echo $this->url(array('controller' => 'result'), 'default', true)?>"; 
		url+='?round='+round.options[index+delta].value;

		    xmlHttpRequest = createXmlHttpRequest();       
		    xmlHttpRequest.onreadystatechange = Callback;       
		    xmlHttpRequest.open("post",url,true); 
		    xmlHttpRequest.send(null);   
    }   
      
}

function createXmlHttpRequest(){ 
    if(window.ActiveXObject){ 
        return new ActiveXObject("Microsoft.XMLHTTP"); 
    }else if(window.XMLHttpRequest){ 
        return new XMLHttpRequest(); 
    } 
}        

function Callback(){ 
    if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
        var valueReturned = xmlHttpRequest.responseText;
		document.getElementById('content').innerHTML = valueReturned;
	    } 
}
</script>
<table class="chart">
	<tr>
		<td width='20'><input type="button" id="previous" value="&#60;&#60;"
			onclick="getResult(-1)" /></td>
		<td width='20'><select id="round"
			onchange="changeSelected(this.options[this.selectedIndex].value)">
<?php
foreach ($this->rounds as $round) :
    ?>		
			<?php
    if ($round == $this->selectedRound) {
        echo "<option value=\"" . $round . "\" selected=\"true\">" . $round .
         "</option>";
    } else {
        echo "<option value=\"" . $round . "\">" . $round . "</option>";
    }
    ?>
    <?php
endforeach
?>

		</select></td>

		<td width='20'><input type="button" name="next" value="&#62;&#62;"
			onclick="getResult(1)" /></td>
	</tr>

</table>

<table class="chart">
	<tr class="labels">
		<td>排名</td>
		<td>姓名</td>
		<td>积分</td>
		<td>赢</td>
		<td>平</td>
		<td>负</td>
		<td>SDO</td>
		<td>SAO</td>
		<td>得票</td>
		<td>失票</td>
		<td>净胜</td>

	</tr>
<?php
foreach ($this->results as $result) :
    ?>
<tr class="labels">
		<td>
      <?php
    echo $this->escape($result->rank)?></td>
		<td>
      <?php
    echo $this->escape($result->name)?></td>
		<td>
      <?php
    echo $this->escape($result->sos)?></td>
		<td>
      <?php
    echo $this->escape($result->win)?></td>
		<td>
      <?php
    echo $this->escape($result->draw)?></td>
		<td>
      <?php
    echo $this->escape($result->lose)?></td>
		<td>
      <?php
    echo $this->escape($result->sdo)?></td>
		<td>
      <?php
    echo $this->escape($result->sao)?></td>
		<td>
      <?php
    echo $this->escape($result->vf)?></td>
		<td>
      <?php
    echo $this->escape($result->va)?></td>
		<td>
      <?php
    echo $this->escape($result->vd)?></td>

	</tr>
<?php
endforeach
?>
</table>
